#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int n, m, i, j, score[100][11];
	char name[100][9];
	double avg[11];
	scanf("%d %d", &n, &m);

	for (i = 0; i < n; i++)
	{
		scanf("%s", name[i]);  //读取学生的姓名
		for (j = 1; j <= m; j++)
			scanf("%d", &score[i][j]);  //读取每一门学科的成绩
	}

	for (i = 0; i < n; i++)  //计算每个人的总分
	{
		score[i][0] = 0;
		for (j = 1; j <= m; j++)  //同一行从左至右
			score[i][0] += score[i][j];
	}

	for (j = 1; j <= m; j++)  //计算每门课程的平均分
	{
		avg[j] = 0;
		for (i = 0; i < n; i++)  //同一列从上至下
			avg[j] += score[i][j];
		avg[j] /= n;
	}

	for (i = 0; i < n; i++)
	{
		printf("%-8s", name[i]);  //输出学生的姓名
		for (j = 0; j <= m; j++)
			printf("%6d", score[i][j]);
		printf("\n");
	}

	printf("average score:");
	for (i = 1; i <= m; i++)  //输出课程平均分
		printf("%6.1lf", avg[i]);
	return 0;
}